#include "page.h"
#include "stdio.h"
#include <stdlib.h>
#include <string.h>
#include "page4.h"
#include "esp_log.h"
#define ANIEND  while(lv_anim_count_running())lv_task_handler();//等待动画完成
extern lv_obj_t* scr;
extern lv_obj_t* scr_body;
lv_obj_t  * calendar;
extern struct _blbl_sys_t blbl_sys_t;
void blbl_calendar(void)
{
    calendar = lv_calendar_create(lv_scr_act(), NULL);
    lv_obj_set_size(calendar, 240, 135);
    lv_obj_align(calendar, NULL, LV_ALIGN_CENTER, 0, 0);
    lv_obj_set_style_local_pad_all(calendar,LV_CALENDAR_PART_HEADER,LV_STATE_DEFAULT,LV_DPI / 32);
    lv_obj_set_style_local_pad_bottom(calendar,LV_CALENDAR_PART_DAY_NAMES,LV_STATE_DEFAULT,LV_DPI / 32);
    lv_obj_set_style_local_outline_pad(calendar,LV_CALENDAR_PART_DATE,LV_STATE_DEFAULT,LV_DPI / 32);
    lv_obj_set_style_local_pad_all(calendar,LV_CALENDAR_PART_DATE,LV_STATE_DEFAULT,0);
    lv_obj_set_style_local_text_font(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DEFAULT, lv_theme_get_font_small());

    /*Set today's date*/
    lv_calendar_date_t today;
    today.year = blbl_sys_t.timeinfo.tm_year+1900;
    today.month = blbl_sys_t.timeinfo.tm_mon+1;
    today.day = blbl_sys_t.timeinfo.tm_mday;

    lv_calendar_set_today_date(calendar, &today);
    lv_calendar_set_showed_date(calendar, &today);
    /*Highlight a few days*/
    // static lv_calendar_date_t highlighted_days[3];       /*Only its pointer will be saved so should be static*/
    // highlighted_days[0].year = 2020;
    // highlighted_days[0].month = 12;
    // highlighted_days[0].day = 11;

    // highlighted_days[1].year = 2020;
    // highlighted_days[1].month = 12;
    // highlighted_days[1].day = 1;

    // highlighted_days[2].year = 2020;
    // highlighted_days[2].month = 11;
    // highlighted_days[2].day = 22;
    //lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3);
}
compment_t c_calendar;
void page5_load()
{
    blbl_calendar();
    c_calendar.start=135;
    c_calendar.end=0;
    c_calendar.obj=calendar;
    c_calendar.start_t=600;
    c_calendar.end_t=600;
    c_calendar.cb=(void *)lv_anim_path_ease_out;
    c_calendar.funcb=(void *)lv_obj_set_y;
    c_calendar.next=NULL;
    obj_move(&c_calendar,1);
    ANIEND
}
void page5_end()
{
    obj_move(&c_calendar,0);
    ANIEND
    lv_obj_del(calendar);
}
void page5_start()
{
    page5_load();
}
